# 数据归一化
import numpy as np


def train_data():
    data_x = []
    data_y = []
    with open('dataset/train_plus.csv') as f:
        for line in f.readlines():
            line_data = line.strip().split(',')
            data_x.append(line_data[1:])
            data_y.append(line_data[0])
    sum_x = []
    for _ in range(13):
        sum_x.append(1)
    for i in data_x:
        for j in range(13):
            i[j] = float(i[j])
            sum_x[j] += i[j]
    for i in range(13):
        sum_x[i] /= len(data_x)
    for i in data_x:
        for j in range(13):
            i[j] /= sum_x[j]
    return data_x, data_y


def test_data():
    data_x = []
    with open('dataset/test_plus.csv') as f:
        for line in f.readlines():
            line_data = line.strip().split(',')
            data_x.append(line_data)
    sum_x = []
    for _ in range(13):
        sum_x.append(1)
    for i in data_x:
        for j in range(13):
            i[j] = float(i[j])
            sum_x[j] += i[j]
    for i in range(13):
        sum_x[i] /= len(data_x)
    for i in data_x:
        for j in range(13):
            i[j] /= sum_x[j]
    return data_x
